#!/bin/bash

echo Using MESA+GPGPUSIM!
#PLEASE CONFIG
export CUDAHOME= #FIXME
export M5_PATH= #FIXME
export NVIDIA_CUDA_SDK_LOCATION= #FIXME
export APITRACE_LIB_PATH= #FIXME

export LD_LIBRARY_PATH=$PWD/mesa/lib
export LD_LIBRARY_PATH=$PWD/mesa/lib/gallium
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/android_libs
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDAHOME/lib
export GPGPUSIM_MESA_ROOT=$PWD

#export MESA_GPGPUSIM_DEBUG="$1"
export PATH=$PATH:$CUDAHOME/bin
export PATH=$PATH:$PWD/gem5/util/term
export CUDA_INSTALL_PATH=$CUDAHOME

#emulator & mesa flags
export ANDROID_GL_SOFTWARE_RENDERER=1
if [ $ANDROID_GL_SOFTWARE_RENDERER -eq 1 ]
then
  echo "Running in OGLES mode"
  export LIBGL_DRIVERS_PATH=$PWD/mesa/lib/gallium
  export ANDROID_EGL_LIB=$PWD/mesa/lib/libEGL.so
  #export ANDROID_GLESv1_LIB=""
  export ANDROID_GLESv2_LIB=$PWD/mesa/lib/libGLESv2.so
else
  echo "Running in OGL mode"
  export LIBGL_DRIVERS_PATH=
  export ANDROID_EGL_LIB=
  export ANDROID_GLESv2_LIB=
fi

